POV-Ray : Newsgroups : povray.advanced-users : Multi dimensional arrays (dim>5) and multi variable type arrays : Multi dimensional arrays (dim>5) and multi variable type arrays Server Time
29 Jul 2024 00:23:31 EDT (-0400)
  Multi dimensional arrays (dim>5) and multi variable type arrays  
From: Jaap Frank
Date: 13 Jul 2003 10:40:59
Message: <3f116f7b$1@news.povray.org>
Maybe this is already known, but it might be handy for someone.

If you want a very high dimensional array, this can be done.
Further you can extract a peace of an array.

// --------- Start of code ----------------------------------------
#declare A = array[2][2][2]
#declare B = array[2][2][2]
#declare C = array[2][2][2]
//    Connect the arrays
#declare B[0][0][0] = C
#declare A[0][0][0] = B
//    Initiate something
#declare A[0][0][0][0][0][0][0][0][0]=0.345;
//    Extract a piece
#declare D = A[0][0][0][0][0][0]

//#declare E = A[0][0][0][0][0] //<-- this gives an error of coarse

#debug str(A[0][0][0][0][0][0][0][0][0],5,3)
// -------   End of code -----------------------------------------

Amazingly POV does not get confused!!

This way it is also possible to put different things into one total array.
In one subarray you can put objects and in other subarrays some
different kind of variables.
So you can build your own multi variable type array.

// --------- Start of code ----------------------------------------
#declare Total = array[3]
#declare Objects = array[2]
#declare Tex = array[2]
 {pigment{color rgb <0,1,0>},
  pigment{color rgbt <1,1,1,0.4>} }
#declare Vars = array[4]{0,1, -1, +1}
#declare Total[0] = Objects
#declare Total[1] = Vars
#declare Total[2] = Tex
#declare Total[0][0] =
 sphere{ Total[1][0], Total[1][1]
 texture { Total[2][0]}}
#declare Total[0][1] =
 box{ Total[1][2], Total[1][3]
 texture { Total[2][1]}}

object {Total[0][0]}
object {Total[0][1]}
light_source { <-20, 40, -20>  color rgb <1,1,1> }
camera {  location <0,0,-3>  look_at 0 }
// -------   End of code -----------------------------------------

Maybe someone can use this someway.

Jaap Frank


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.